<script type="text/javascript">

//
$(document).ready();

function deleteItem(itemid, campaignid) {
	if(confirm('Delete record?')){ 
			$.ajax({url:'/soa/deleteitem/itemid/'+itemid,success:function(data){alert('Item has been removed');location.href=('/soa/additems/campaignid/'+campaignid);}});
		}  
}

</script>
<?php $this->jQuery()->onLoadCaptureStart(); ?>
				jQuery('#inventoryItem').change(function() 
				{ 
					$.post('/soa/getiteminfo/inventoryItem/'+$('#inventoryItem').val()+'/customerNumber/'+$('#tblCustomerNumber').html(),{}, 
					function(data) {
						$('#tblItemDescription').html(data['inventoryItemDesc']);
						$('#tblDivision').html(data['divisionDesc']);
						$('#tblEAN').html(data['eanCode']);
						$('#tblChannel').html(data['qtyCustomerInventory']+' units');
						$('#tblSellthrough').html(data['week1']+' - '+data['week2']+ ' - ' +data['week3']) 
					}, 'json');
				});
				
				jQuery('#planQty').change(function()
				{
					$('#totalCost').val(($('#planQty').val() * $('#price').val()));
				});
				
				
	<?php $this->jQuery()->onLoadCaptureEnd(); ?>

<h1>
	<?php echo $this->pageTitle; ?>
</h1>

<div id="content">
	<div id="normaltable">
		<table>
			<thead>
				<tr>
					<th>Customer</th>
					<th>Budget</th>
					<th>Campaign Description</th>
					<th>Starting date</th>
					<th>Ending date</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td id="tblCustomerNumber"><?php echo $this->parentCampaign->getCustomerNumber(); ?></td>
					<td><?php echo $this->parentCampaign->getBudgetCategory(); ?></td>
					<td><?php echo $this->parentCampaign->getCampaignDesc(); ?></td>
					<td><?php $startdate = new DateTime($this->parentCampaign->getStartDate()); echo $startdate->format('d.m.Y'); ?></td>
					<td><?php $enddate = new DateTime($this->parentCampaign->getEndDate()); echo $enddate->format('d.m.Y'); ?></td>
				</tr>
			</tbody>
		</table>
	</div>


<!--  Item Section -->
<h1>Campaign Items</h1>
<!-- Show available Items -->
<div id="normaltable">
<table>
<thead>
	<tr>
		<td>InventoryItem</td><td>Price</td><td>Plan Qty</td><td></td><td></td>
	</tr>
</thead>
<tbody>
<?php 
foreach($this->soaItems as $row) {
		echo '<tr>';
		
		echo '<td>'.$row['inventoryItem'].'</td><td>'.$row['price'].'</td><td>'.$row['planQty'].'</td>';
		
		echo '<td><a href="#">edit</a></td><td><a href="#" onClick="deleteItem('.$row['id'].','.$this->parentCampaign->getId().')">delete</a></td>';
		
		echo '</tr>';
}
 

?>
</tbody>
</table>
<h1>Add Item to campaign</h1>
</div>
<!-- Enter Section -->
<table>
	<tr>
		<td width="400">
				<!-- Print Form to enter Items -->
				<?php echo $this->form; ?>
		</td>
		<td valign="top">
			<!-- Print info for entered item -->
			<div id="normaltable">
			<table>
				<thead>
					<tr>
						<th colspan="2">Product Info</th>
					</tr>
				</thead>
				<tbody>
				<tr>
					<td>Item Description:</td>
					<td id="tblItemDescription"></td>
				</tr>
				<tr>
					<td>EAN:</td>
					<td id="tblEAN"></td>
				</tr>
				<tr>
					<td>Division:</td>
					<td id="tblDivision"></td>
				</tr>
				</tbody>
				<thead>
					<tr>
						<th colspan="2">Pricing</th>
					</tr>
				</thead>
				<tbody>
				<tr>
					<td>Current SRP:</td>
					<td id="tblCurrentSRP"></td>
				</tr>
				<tr>
					<td>Approved PricePoint:</td>
					<td id="tblCurrentSRP"></td>
				</tr>
				<thead>
					<tr>
						<th colspan="2">Sellthrough & Channel</th>
					</tr>
				</thead>
				<tbody>
				<tr>
					<td>Current Customer Inventory:</td>
					<td id="tblChannel"></td>
				</tr>
				<tr>
					<td>Sellthrough last 3 Weeks:</td>
					<td id="tblSellthrough"></td>
				</tr>
				</tbody>
			</table>
			</div>
		</td>
	</tr>
</table>

</div>
